<% layout("/WEB-INF/view/console/skins/skin_2/layout.html", {}) {
%>
<link rel="stylesheet" href="${ctxPath}/plugin/My97DatePicker/skin/WdatePicker.css" type="text/css">
<script type='text/javascript' src='${ctxPath}/plugin/My97DatePicker/WdatePicker.js'></script>
<script src="/static/console/js/postDownload.js"></script>
<div class="row">
    <div class="col-md-12">
        <div class="widget-container fluid-height clearfix">
            <div class="widget-content padded clearfix">
                <div class='row'>
                    <div class='col-md-12'>
                        <form name="boProxyOrder_form" id="boProxyOrder_form" class='form-inline'>
 <div class='form-group col-md-4' style='margin-top: 10px;'>
 <label title='订单状态' >订单状态：</label>
   <div class="checkbox">
       <input type="checkbox" name="payType" value="0"> 未付款
       <input type="checkbox" name="payType" value="1"> 已付款
       <input type="checkbox" name="payType" value="2"> 已取消
       <input type="checkbox" name="payType" value="3"> 退货
   </div>
<!-- <select class="form-control" id="orderPayState" name="orderPayState">
 <option  value="">请选择...</option>
 	<option  value="0">未付款</option>
 	<option  value="1">已付款</option>
 	<option  value="2">已取消</option>
 	<option  value="3">退货</option>
 </select>-->
 </div>
 <div class='form-group col-md-4' style='margin-top: 10px;'>
 <label title='配送状态' >配送状态：</label>
 <select class="form-control" id="orderDeliveryState" name="orderDeliveryState">
 <option  value="">请选择...</option>
 	<option  value="0">未配送</option>
 	<option  value="1">正在配送</option>
 	<option  value="2">已签收</option>
 </select>
 </div>
                            <div class='form-group col-md-4' style='margin-top: 10px;'>
                                <label title='订单锁定状态' >订单锁定...：</label>
                                <select class="form-control" id="orderLockState" name="orderLockState">
                                    <option  value="">请选择...</option>
                                    <option  value="0">正常</option>
                                    <option  value="1">正在取消订单</option>
                                    <option  value="2">正在退货</option>
                                    <option  value="4">订单开始处理</option>
                                </select>
                            </div>
                            <div class='form-group col-md-4' style='margin-top: 10px;'>
                                <label title='是否开发票' >是否开发...：</label>
                                <select class="form-control" id="orderInvoice" name="orderInvoice">
                                    <option  value="">请选择...</option>
                                    <option  value="0">否</option>
                                    <option  value="1">是</option>
                                </select>
                            </div>
                            <div class='form-group col-md-4' style='margin-top: 10px;'>
                                <label title='开始时间'  >开始时间：</label>
                                <input  onkeyup='boProxyConsoleGrid.enterToQuery(event);' type='text' class='form-control' onClick="WdatePicker()" id='startTime' placeholder=''>
                            </div>
                            <div class='form-group col-md-4' style='margin-top: 10px;'>
                                <label title='结束时间'  >结束时间：</label>
                                <input  onkeyup='boProxyConsoleGrid.enterToQuery(event);' type='text' class='form-control' onClick="WdatePicker()" id='endTime' placeholder=''>
                            </div>
                            <div class='form-group col-md-4' style='margin-top: 10px;'>
                                <label>商品</label>
                                    <select class="form-control" id="goodsId"
                                            name="goodsId" check-type="required">
                                    </select>
                            </div>
                            <script type="text/javascript">
                                $(function($){
                                    componentSelectInit(
                                        {
                                            ctxPath:'${ctxPath}',
                                            tableName:"bo_goods",
                                            showValueField:"goods_title",
                                            valueField:"goods_id",
                                            selectId:"goodsId"
                                        }
                                        ,function(){
                                        });
                                });
                            </script>
                        </form>
                    </div>
                </div>


                <div class='row'>
                    <div align="center">
                        <button type='button' class='btn btn-default' id='boProxyOrderQuerySearch'>查询</button>
                        <button type='button' class='btn btn-default' id='boProxyOrderReset'>重置</button>
                    </div>
                </div>
                 <div id="boProxyOrderToolbar" class="btn-group">
               <button type="button" class="btn btn-default" onclick="downTable('boProxyOrder');">
                    导出
                </button>
               <!--
                     <button type="button" class="btn btn-default" onclick="consoleOpenWindow('boProxyTrace','${ctxPath}/console/bo_proxy_trace/add','新增')">
                         录入订单
                     </button> -->
            </div>

                     <div class='row'>
                              <div class='col-md-12'>
                                  <table id="boProxyOrder" data-toggle="table"
                                         data-url="${ctxPath}/console/bo_proxy_order/json/fenxiao"
                                         data-pagination="true"
                                         data-query-params="boProxyOrderLoadParam"
                                         method="post"
                                         data-side-pagination="server"
                                         data-show-refresh="true"
                                         data-show-toggle="true"
                                         data-pagination-loop="false"
                                         data-show-columns="true"
                                         data-toolbar="#boProxyOrderToolbar">
                                      <thead>
                                      <tr>
                                           <th data-checkbox="true"></th>
                                            <th data-field='orderId' data-visible='false'>ID</th>
  <th data-sortable='true' data-field='orderNumber' data-visible='false'>订单号</th>
                                          <th data-sortable='true' data-field='proxyName'>用户</th>

  <th data-sortable='true' data-field='createTime' data-formatter="consoleTableDateFormat">创建时间</th>
                                          <th data-sortable='false' data-field='goodsName'>商品名称</th>
                                          <th data-sortable='false' data-field='goodsPrice'>商品单价</th>
                                          <th data-sortable='false' data-field='goodsNumber'>商品数量</th>
  <th data-sortable='true' data-field='orderFreight'>运费</th>

                                          <th data-sortable='true' data-field='orderGoodsPrice'>商品费用</th>
                                          <th data-field='orderType' data-sortable='true' data-formatter='boProxyOrderorderorderTypeFormatter'>订单类型</th>
                                          <th data-field='orderDeliveryState' data-sortable='true' data-formatter='boProxyOrderorder_delivery_stateFormatter'>配送状态</th>
                                          <th data-field='orderPayState' data-sortable='true' data-formatter='boProxyOrderorder_pay_stateFormatter'>订单状态</th>
                                          <th data-field='orderLockState' data-sortable='true' data-formatter='boProxyOrderorder_lock_stateFormatter'>订单锁定状态</th>

                                          <th data-field='orderOperState' data-visible='false'>订单锁定状态</th>

                                          <th data-sortable='false' data-field='shippingConsignee'>收货人</th>
                                          <th data-sortable='false' data-field='shippingPhone'>收货人电话</th>
                                          <th data-sortable='false' data-field='shippingDetailAddress' data-formatter='addressFormat'>收货地址</th>
                                          <th data-field='shippingCounty' data-visible='false'></th>
                                          <th data-field='shippingCity' data-visible='false'></th>
                                          <th data-field='shippingProvince' data-visible='false'></th>


                                          <th data-field='orderRemark' data-visible='true'>备注</th>
  <th data-field='orderId' data-formatter='boProxyOrderTableOperate'>操作</th>

 
                                      </tr>
                                      </thead>
                                  </table>
                              </div>
                     </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function downTable(id) {
        var table2=$("#"+id);
        var table3 = "<table style='border: #c0c0c0 solid 1px;border-collapse:collapse;'  >";
        table2.find("tr").each(function (i,o) {
            table3+="<tr style='border: #c0c0c0 solid 1px'>";
            if(i==0){
                $(o).find("th").each(function (j,d) {
                    table3+="<th style='border: #c0c0c0 solid 1px'>"+$(d).text()+"</th>";
                })
            }else{
                $(o).find("td").each(function (j,d) {
                    table3+="<td style='border: #c0c0c0 solid 1px'>"+$(d).text()+"</td>";
                })
            }

            table3+="</tr>";
        });
        table3+="</table>";
        console.log(table3);
        consolePostDownload({

            url:'/console/export/excel', //请求的url

            data:{table:table3}//要发送的数据

        });
    }
    var shipping="100,104";
    var shippingApply="100";
     var boProxyOrderConsoleGrid =new consoleGrid({table_id:"boProxyOrder"});
     boProxyOrderConsoleGrid.init();

     function boProxyOrderorder_orderInvoice(value) {
         var showValue='';
         switch(value+''){
             case '0':
                 showValue = '否';
                 break;
             case '1':
                 showValue = '是';
                 break;
         }
         if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){
             return '<span class="label label-warning">'+showValue+'</span>';
         }else{
             return '<span class="label label-info">'+showValue+'</span>';
         }
     }
    function boProxyOrderorderorderTypeFormatter(value)
    {
        var showValue='试吃订单';
        switch(value+''){
            case '2':
                showValue = '普通订单';
                break;
        }
        if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){
            return '<span class="label label-warning">'+showValue+'</span>';
        }else{
            return '<span class="label label-info">'+showValue+'</span>';
        }
    }
     function boProxyOrderTableOperate(value,o,i){
         var state = o.orderOperState;
         var btn = "";
         var detail ="<button type='button' class='btn btn-xs btn-default' onclick='info(\""+value+"\");'>详情</button> ";
         btn+=detail;
    if(shipping.indexOf(state)!=-1){
        btn+="<button type='button' class='btn btn-xs btn-default' onclick='fahuo(\""+value+"\");'>发货</button> ";
    }
         if(shippingApply.indexOf(state)!=-1){
             btn+="<button type='button' class='btn btn-xs btn-info' onclick='handleOrder(\""+value+"\");'>发货申请</button> ";
         }


         return btn ;
     }
    function info(v){
        window.open("${ctxPath}/console/bo_proxy_order/info/"+v,"_blank");
    }
     function fahuo(v){
         window.open("${ctxPath}/console/bo_proxy_order/fenxiao/shipments/page/"+v,"_blank");
     }
    function boProxyOrderLoadParam(params){
         var vs =[];
         $("input[name='payType']:checked").each(function(){
             vs.push($(this).val());
        });
        params.query=boProxyOrderQueryString();
        params.goodsId=$("#goodsId").val();
        params.payType=vs.join(",")
        params.startTime=$("#startTime").val();
        params.endTime=$("#endTime").val();
        return params;
    }
     function boProxyOrderQueryString() {
         var objQuery = new Object();
                objQuery.orderNumber=$('#orderNumber').val()==''?null:$('#orderNumber').val();
         objQuery.orderPayState=$('#orderPayState').val()==''?null:$('#orderPayState').val();
         objQuery.proxyId=$('#proxyId').val()==''?null:$('#proxyId').val();
     objQuery.orderDeliveryState=$('#orderDeliveryState').val()==''?null:$('#orderDeliveryState').val(); 
     objQuery.orderExpressNumber=$('#orderExpressNumber').val()==''?null:$('#orderExpressNumber').val();
     objQuery.shippingAddress=$('#shippingAddress').val()==''?null:$('#shippingAddress').val();
     objQuery.shippingAddress=$('#shippingAddress').val()==''?null:$('#shippingAddress').val();
         objQuery.orderLockState=$('#orderLockState').val()==''?null:$('#orderLockState').val();
        // objQuery.orderType=2;
         var queryString = JSON.stringify(objQuery);
         return queryString;
     }
function addressFormat(v,o,i) {
        return o.shippingProvince+" "+o.shippingCity+" "+o.shippingCounty+" "+v;
}
     function boProxyOrderorder_pay_stateFormatter(value) 
   { 
       var showValue=''; 
       switch(value+''){
       case '0': 
       showValue = '未付款';
       break;
       case '1': 
       showValue = '已付款';
       break;
       case '2': 
       showValue = '已取消';
       break;
       case '3': 
       showValue = '退货';
       break;
       }
    if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){    
       return '<span class="label label-warning">'+showValue+'</span>';
   }else{
       return '<span class="label label-info">'+showValue+'</span>';
   }
   }
 function boProxyOrderorder_delivery_stateFormatter(value) 
   { 
       var showValue=''; 
       switch(value+''){
       case '0': 
       showValue = '未配送';
       break;
       case '1': 
       showValue = '正在配送';
       break;
       case '2': 
       showValue = '已签收';
       break;
       }
    if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){    
       return '<span class="label label-warning">'+showValue+'</span>';
   }else{
       return '<span class="label label-info">'+showValue+'</span>';
   }
   }
     function boProxyOrderorder_lock_stateFormatter(value)
     {
         var showValue='';
         switch(value+''){
             case '0':
                 showValue = '正常';
                 break;
             case '1':
                 showValue = '正在取消订单';
                 break;
             case '2':
                 showValue = '正在退货';
                 break;
             case '3':
                 showValue = '正在发货';
                 break;
             case '4':
                 showValue = '开始发货';
                 break;

         }
         if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){
             return '<span class="label label-warning">'+showValue+'</span>';
         }else{
             return '<span class="label label-info">'+showValue+'</span>';
         }
     }
function handleOrder(id) {
    $.post("/console/bo_proxy_order/fenxiao/shipments/apply/"+id,function (data) {
        if(data.http_status=="1"){
            $("#boProxyOrder").bootstrapTable("refresh");
            alert("发货处理成功");

        }else{
            alert(data.message);
        }
    })
}
</script>
<%} %>
 